<?php 
/***********************************************************************************************/
/* Social Widget
/***********************************************************************************************/

	class Social_Widget extends WP_Widget {
	
		public function __construct() {
			parent::__construct(
				'social_widget',
				'Redox Widget: Social Networks',
				array('description' => __('Displays Social Network Links', 'redox_localize'))
			); 
		}
		
		public function form($instance) {
			$defaults = array(
				'title' => 'Find Us On',
				'githuburl' => '',
				'linkedinurl' => '',
				'facebookurl' => '',
				'rdiourl' => '',
				'evernoteurl' => '',
				'soundcloudurl' => '',
				'diggurl' => '',
				'stumbleuponurl' => '',
				'flickrurl' => '',
				'googleplusurl' => '',
				'dribbbleurl' => '',
				'spotifyurl' => '',
				'skypeurl' => '',
				'behanceurl' => '',
				'bloggerurl' => '',
				'vimeourl' => '',
				'pinteresturl' => '',
				'instagramurl' => '',
				'youtubeurl' => '',
				'redditurl' => '',
				'twitterurl' => '',
				'tumblrurl' => '',
				'lastfmurl' => '',
				'dropboxurl' => '',
				'steamurl' => '',
				'stackoverflowurl' => '',
				'foursquareurl' => '',
				'paypalurl' => '',
				'websiteurl' => '',
				'email' => '',

			);
			
			$instance = wp_parse_args((array) $instance, $defaults);
			
			?>
			
			<p>
				<label for="<?php echo $this->get_field_id('title') ?>"><?php _e('Title:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('githuburl') ?>"><?php _e('Github URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('githuburl'); ?>" name="<?php echo $this->get_field_name('githuburl'); ?>" value="<?php echo esc_attr($instance['githuburl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('linkedinurl') ?>"><?php _e('LinkedIn URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('linkedinurl'); ?>" name="<?php echo $this->get_field_name('linkedinurl'); ?>" value="<?php echo esc_attr($instance['linkedinurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('facebookurl') ?>"><?php _e('Facebook URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('facebookurl'); ?>" name="<?php echo $this->get_field_name('facebookurl'); ?>" value="<?php echo esc_attr($instance['facebookurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('rdiourl') ?>"><?php _e('Rdio URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('rdiourl'); ?>" name="<?php echo $this->get_field_name('rdiourl'); ?>" value="<?php echo esc_attr($instance['rdiourl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('evernoteurl') ?>"><?php _e('Evernote URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('evernoteurl'); ?>" name="<?php echo $this->get_field_name('evernoteurl'); ?>" value="<?php echo esc_attr($instance['evernoteurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('soundcloudurl') ?>"><?php _e('Soundcloud URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('soundcloudurl'); ?>" name="<?php echo $this->get_field_name('soundcloudurl'); ?>" value="<?php echo esc_attr($instance['soundcloudurl']); ?>" />
			</p>	
			<p>
				<label for="<?php echo $this->get_field_id('diggurl') ?>"><?php _e('Digg URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('diggurl'); ?>" name="<?php echo $this->get_field_name('diggurl'); ?>" value="<?php echo esc_attr($instance['diggurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('stumbleuponurl') ?>"><?php _e('StumbleUpon URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('stumpleuponurl'); ?>" name="<?php echo $this->get_field_name('stumbleuponurl'); ?>" value="<?php echo esc_attr($instance['stumbleuponurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('flickrurl') ?>"><?php _e('Flickr URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('flickrurl'); ?>" name="<?php echo $this->get_field_name('flickrurl'); ?>" value="<?php echo esc_attr($instance['flickrurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('googleplusurl') ?>"><?php _e('GooglePlus URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('googleplusurl'); ?>" name="<?php echo $this->get_field_name('googleplusurl'); ?>" value="<?php echo esc_attr($instance['googleplusurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('dribbbleurl') ?>"><?php _e('Dribbble URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('dribbbleurl'); ?>" name="<?php echo $this->get_field_name('dribbbleurl'); ?>" value="<?php echo esc_attr($instance['dribbbleurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('spotifyurl') ?>"><?php _e('Spotify URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('spotifyurl'); ?>" name="<?php echo $this->get_field_name('spotifyurl'); ?>" value="<?php echo esc_attr($instance['spotifyurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('skypeurl') ?>"><?php _e('Skype URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('skypeurl'); ?>" name="<?php echo $this->get_field_name('skypeurl'); ?>" value="<?php echo esc_attr($instance['skypeurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('behanceurl') ?>"><?php _e('Behance URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('behanceurl'); ?>" name="<?php echo $this->get_field_name('behanceurl'); ?>" value="<?php echo esc_attr($instance['behanceurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('bloggerurl') ?>"><?php _e('Blogger URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('bloggerurl'); ?>" name="<?php echo $this->get_field_name('bloggerurl'); ?>" value="<?php echo esc_attr($instance['bloggerurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('vimeourl') ?>"><?php _e('Vimeo URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('vimeourl'); ?>" name="<?php echo $this->get_field_name('vimeourl'); ?>" value="<?php echo esc_attr($instance['vimeourl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('pinteresturl') ?>"><?php _e('Pinterest URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('pinteresturl'); ?>" name="<?php echo $this->get_field_name('pinteresturl'); ?>" value="<?php echo esc_attr($instance['pinteresturl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('instagramurl') ?>"><?php _e('Instagram URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('instagramurl'); ?>" name="<?php echo $this->get_field_name('instagramurl'); ?>" value="<?php echo esc_attr($instance['instagramurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('youtubeurl') ?>"><?php _e('Youtube URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('youtubeurl'); ?>" name="<?php echo $this->get_field_name('youtubeurl'); ?>" value="<?php echo esc_attr($instance['youtubeurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('redditurl') ?>"><?php _e('Reddit URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('redditurl'); ?>" name="<?php echo $this->get_field_name('redditurl'); ?>" value="<?php echo esc_attr($instance['redditurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('twitterurl') ?>"><?php _e('Twitter URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('twitterurl'); ?>" name="<?php echo $this->get_field_name('twitterurl'); ?>" value="<?php echo esc_attr($instance['twitterurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('tumblrurl') ?>"><?php _e('Tumblr URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('tumblrurl'); ?>" name="<?php echo $this->get_field_name('tumblrurl'); ?>" value="<?php echo esc_attr($instance['tumblrurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('lastfmurl') ?>"><?php _e('LastFM URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('lastfmurl'); ?>" name="<?php echo $this->get_field_name('lastfmurl'); ?>" value="<?php echo esc_attr($instance['lastfmurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('dropboxurl') ?>"><?php _e('Dropbox URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('dropboxurl'); ?>" name="<?php echo $this->get_field_name('dropboxurl'); ?>" value="<?php echo esc_attr($instance['dropboxurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('steamurl') ?>"><?php _e('Steam URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('steamurl'); ?>" name="<?php echo $this->get_field_name('steamurl'); ?>" value="<?php echo esc_attr($instance['steamurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('stackoverflowurl') ?>"><?php _e('StackOverflow URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('stackoverflowurl'); ?>" name="<?php echo $this->get_field_name('stackoverflowurl'); ?>" value="<?php echo esc_attr($instance['stackoverflowurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('foursquareurl') ?>"><?php _e('FourSquare URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('foursquareurl'); ?>" name="<?php echo $this->get_field_name('foursquareurl'); ?>" value="<?php echo esc_attr($instance['foursquareurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('paypalurl') ?>"><?php _e('PayPal URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('paypalurl'); ?>" name="<?php echo $this->get_field_name('paypalurl'); ?>" value="<?php echo esc_attr($instance['paypalurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('websiteurl') ?>"><?php _e('Website URL:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('websiteurl'); ?>" name="<?php echo $this->get_field_name('websiteurl'); ?>" value="<?php echo esc_attr($instance['websiteurl']); ?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('email') ?>"><?php _e('Email:', 'redox_localize'); ?></label>
				<input type="text" size="27" id="<?php echo $this->get_field_id('email'); ?>" name="<?php echo $this->get_field_name('email'); ?>" value="<?php echo esc_attr($instance['email']); ?>" />
			</p>

			<?php
		}
		
		public function update($new_instance, $old_instance) {

			$instance = $old_instance;
			
			$instance['title'] = $new_instance['title'];

			$instance['githuburl'] = $new_instance['githuburl'];
			
			$instance['linkedinurl'] = $new_instance['linkedinurl'];

			$instance['facebookurl'] = $new_instance['facebookurl'];

			$instance['rdiourl'] = $new_instance['rdiourl'];

			$instance['evernoteurl'] = $new_instance['evernoteurl'];
			
			$instance['soundcloudurl'] = $new_instance['soundcloudurl'];

			$instance['diggurl'] = $new_instance['diggurl'];

			$instance['stumbleuponurl'] = $new_instance['stumbleuponurl'];

			$instance['flickrurl'] = $new_instance['flickrurl'];

			$instance['googleplusurl'] = $new_instance['googleplusurl'];

			$instance['dribbbleurl'] = $new_instance['dribbbleurl'];

			$instance['spotifyurl'] = $new_instance['spotifyurl'];

			$instance['skypeurl'] = $new_instance['skypeurl'];

			$instance['behanceurl'] = $new_instance['behanceurl'];

			$instance['bloggerurl'] = $new_instance['bloggerurl'];

			$instance['vimeourl'] = $new_instance['vimeourl'];

			$instance['pinteresturl'] = $new_instance['pinteresturl'];

			$instance['instagramurl'] = $new_instance['instagramurl'];

			$instance['youtubeurl'] = $new_instance['youtubeurl'];

			$instance['redditurl'] = $new_instance['redditurl'];

			$instance['twitterurl'] = $new_instance['twitterurl'];
			
			$instance['tumblrurl'] = $new_instance['tumblrurl'];

			$instance['lastfmurl'] = $new_instance['lastfmurl'];

			$instance['dropboxurl'] = $new_instance['dropboxurl'];

			$instance['steamurl'] = $new_instance['steamurl'];

			$instance['stackoverflowurl'] = $new_instance['stackoverflowurl'];

			$instance['foursquareurl'] = $new_instance['foursquareurl'];

			$instance['paypalurl'] = $new_instance['paypalurl'];

			$instance['websiteurl'] = $new_instance['websiteurl'];

			$instance['email'] = $new_instance['email'];


			return $instance;
		}
		
		public function widget($args, $instance) {
			extract($args);

			$title = $instance['title'];
			
			$githuburl = $instance['githuburl'];

			$linkedinurl = $instance['linkedinurl'];

			$facebookurl = $instance['facebookurl'];

			$rdiourl = $instance['rdiourl'];

			$evernoteurl = $instance['evernoteurl'];

			$soundcloudurl = $instance['soundcloudurl'];

			$diggurl = $instance['diggurl'];

			$stumbleuponurl = $instance['stumbleuponurl'];
			
			$flickrurl = $instance['flickrurl'];

			$googleplusurl = $instance['googleplusurl'];

			$dribbbleurl = $instance['dribbbleurl'];

			$spotifyurl = $instance['spotifyurl'];

			$skypeurl = $instance['skypeurl'];

			$behanceurl = $instance['behanceurl'];

			$bloggerurl = $instance['bloggerurl'];

			$vimeourl = $instance['vimeourl'];

			$pinteresturl = $instance['pinteresturl'];

			$instagramurl = $instance['instagramurl'];

			$youtubeurl = $instance['youtubeurl'];

			$redditurl = $instance['redditurl'];

			$twitterurl = $instance['twitterurl'];

			$tumblrurl = $instance['tumblrurl'];

			$lastfmurl = $instance['lastfmurl'];

			$dropboxurl = $instance['dropboxurl'];

			$steamurl = $instance['steamurl'];

			$stackoverflowurl = $instance['stackoverflowurl'];

			$foursquareurl = $instance['foursquareurl'];

			$paypalurl = $instance['paypalurl'];

			$websiteurl = $instance['websiteurl'];

			$email = $instance['email'];

			echo '<div class="widget social post">'; 
						echo '<div class="social-networks">'; 

			if ($title) { 
				echo '<h3 class="widget-title social-widget-title">' . $title . '</h3>';
			}
			

			if ($githuburl) { 
					echo "<a href='" . $githuburl . "'>
						<div class='icon'>
							<i class='icon-github'>
							</i>
						</div>
					</a>";
			}

			if ($linkedinurl) { 
					echo "<a href='" . $linkedinurl . "'>
						<div class='icon'>
							<i class='icon-linkedin'>
							</i>
						</div>
					</a>";
			}

			if ($facebookurl) { 
					echo "<a href='" . $facebookurl . "'>
						<div class='icon'>
							<i class='icon-facebook'>
							</i>
						</div>
					</a>";
			}

			if ($rdiourl) { 
					echo "<a href='" . $rdiourl . "'>
						<div class='icon'>
							<i class='icon-rdio'>
							</i>
						</div>
					</a>";
			}

			if ($evernoteurl) { 
					echo "<a href='" . $evernoteurl . "'>
						<div class='icon'>
							<i class='icon-evernote'>
							</i>
						</div>
					</a>";
			}

			if ($soundcloudurl) { 
					echo "<a href='" . $soundcloudurl . "'>
						<div class='icon'>
							<i class='icon-soundcloud'>
							</i>
						</div>
					</a>";
			}

			if ($diggurl) { 
					echo "<a href='" . $diggurl . "'>
						<div class='icon'>
							<i class='icon-digg'>
							</i>
						</div>
					</a>";
			}

			if ($stumbleuponurl) { 
					echo "<a href='" . $stumbleuponurl . "'>
						<div class='icon'>
							<i class='icon-stumbleupon'>
							</i>
						</div>
					</a>";
			}

			if ($flickrurl) { 
					echo "<a href='" . $flickrurl . "'>
						<div class='icon'>
							<i class='icon-flickr'>
							</i>
						</div>
					</a>";
			}

			if ($googleplusurl) { 
					echo "<a href='" . $googleplusurl . "'>
						<div class='icon'>
							<i class='icon-gplus'>
							</i>
						</div>
					</a>";
			}

			if ($dribbbleurl) { 
					echo "<a href='" . $dribbbleurl . "'>
						<div class='icon'>
							<i class='icon-dribbble'>
							</i>
						</div>
					</a>";
			}

			if ($spotifyurl) { 
					echo "<a href='" . $spotifyurl . "'>
						<div class='icon'>
							<i class='icon-spotify'>
							</i>
						</div>
					</a>";
			}

			if ($skypeurl) { 
					echo "<a href='" . $skypeurl . "'>
						<div class='icon'>
							<i class='icon-skype'>
							</i>
						</div>
					</a>";
			}

			if ($behanceurl) { 
					echo "<a href='" . $behanceurl . "'>
						<div class='icon'>
							<i class='icon-behance'>
							</i>
						</div>
					</a>";
			}

			if ($bloggerurl) { 
					echo "<a href='" . $bloggerurl . "'>
						<div class='icon'>
							<i class='icon-blogger'>
							</i>
						</div>
					</a>";
			}

			if ($vimeourl) { 
					echo "<a href='" . $vimeourl . "'>
						<div class='icon'>
							<i class='icon-vimeo'>
							</i>
						</div>
					</a>";
			}

			if ($pinteresturl) { 
					echo "<a href='" . $pinteresturl . "'>
						<div class='icon'>
							<i class='icon-pinterest'>
							</i>
						</div>
					</a>";
			}

			if ($instagramurl) { 
					echo "<a href='" . $instagramurl . "'>
						<div class='icon'>
							<i class='icon-instagram'>
							</i>
						</div>
					</a>";
			}

			if ($youtubeurl) { 
					echo "<a href='" . $youtubeurl . "'>
						<div class='icon'>
							<i class='icon-youtube'>
							</i>
						</div>
					</a>";
			}

			if ($redditurl) { 
					echo "<a href='" . $redditurl . "'>
						<div class='icon'>
							<i class='icon-reddit'>
							</i>
						</div>
					</a>";
			}

			if ($twitterurl) { 
					echo "<a href='" . $twitterurl . "'>
						<div class='icon'>
							<i class='icon-twitter'>
							</i>
						</div>
					</a>";
			}

			if ($tumblrurl) { 
					echo "<a href='" . $tumblrurl . "'>
						<div class='icon'>
							<i class='icon-tumblr'>
							</i>
						</div>
					</a>";
			}

			if ($lastfmurl) { 
					echo "<a href='" . $lastfmurl . "'>
						<div class='icon'>
							<i class='icon-lastfm'>
							</i>
						</div>
					</a>";
			}

			if ($dropboxurl) { 
					echo "<a href='" . $dropboxurl . "'>
						<div class='icon'>
							<i class='icon-dropbox'>
							</i>
						</div>
					</a>";
			}

			if ($steamurl) { 
					echo "<a href='" . $steamurl . "'>
						<div class='icon'>
							<i class='icon-steam'>
							</i>
						</div>
					</a>";
			}

			if ($stackoverflowurl) { 
					echo "<a href='" . $stackoverflowurl . "'>
						<div class='icon'>
							<i class='icon-stackoverflow'>
							</i>
						</div>
					</a>";
			}

			if ($foursquareurl) { 
					echo "<a href='" . $foursquareurl . "'>
						<div class='icon'>
							<i class='icon-foursquare'>
							</i>
						</div>
					</a>";
			}

			if ($paypalurl) { 
					echo "<a href='" . $paypalurl . "'>
						<div class='icon'>
							<i class='icon-paypal'>
							</i>
						</div>
					</a>";
			}

			if ($websiteurl) { 
					echo "<a href='" . $websiteurl . "'>
						<div class='icon'>
							<i class='icon-globe'>
							</i>
						</div>
					</a>";
			}

			if ($email) { 
					echo "<a href='mailto:" . $email . "'>
						<div class='icon'>
							<i class='icon-mail-alt'>
							</i>
						</div>
					</a>";
			}

			echo '</div>'; 
			echo '</div>'; 
						
		}
	}

	register_widget('Social_Widget');

?>